<template>
    <div>
        <h1>
            <b class="el-icon-collection"></b>
            <span>我的收藏</span>
        </h1>
        <div class="shop">
            <el-row :gutter="10">
                <el-col
                    :span="5"
                    v-for="item in $store.state.shoplist"
                    :key="item._id"
                >
                    <i class="el-icon-close" @click="remove(item)"></i>
                    <div class="grid-content">
                        <el-image
                            lazy-load
                            :src="
                                'http://47.115.85.237:3000/' +
                                    item.product_picture
                            "
                        />
                        <p>{{ item.product_name }}</p>
                        <p>{{ item.product_title }}</p>
                        <p>
                            <span>￥{{ item.product_price }}</span>
                        </p>
                    </div>
                </el-col>
            </el-row>
        </div>
    </div>
</template>

<script>
import { Dialog } from "vant";
export default {
    data() {
        return {};
    },
    methods: {
        handleClose(done) {
            done();
        },
        //删除单个商品
        remove(item) {
            Dialog.alert({
                message: "确认删除该商品？",
            }).then(() => {
                this.$store.commit("remove", item);
            });
        },
    },
};
</script>

<style lang="scss" scoped>
h1 {
    width: 100%;
    border-bottom: 3px solid orangered;
    b {
        font-size: 36px;
        color: orangered;
    }
    span {
        font-size: 40px;
    }
}
.shop {
    width: 1400px;
    margin: 10px auto;
    background-color: rgb(247, 245, 245);
    i {
        float: right;
        font-size: 20px;
        color: gray;
        margin-right: 10px;
        margin-top: 10px;
        position: absolute;
        z-index: 99;
        right: 10px;
        top: 0px;
    }
    .el-col:hover {
        transition: all 1s;
        box-shadow: 5px 5px 5px #888888;
        transform: scale(1.02);
    }
    .el-col {
        background-color: #fff;
        height: 385px;
        width: 270px;
        margin-bottom: 10px;
        margin-left: 10px;
        position: relative;
        .el-image {
            width: 100%;
        }
        p {
            text-align: center;
            font-size: 16px;
            margin: 0;
            padding: 5px;
        }
        :nth-child(3) {
            color: gray;
        }
        :nth-child(4) {
            span {
                font-size: 20px;
                color: orange;
            }
        }
    }
}
</style>
